﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace nextGeneration_app
{
    public partial class teacher_forgotPassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void probtn_Click(object sender, EventArgs e){

            Session["UserID"] = forgetuser.Text;
            Session["email"] = usertxb.Text;
            Session["userTypes"] = ddlUserType.SelectedValue;
            //check the exicting email and userID

            string originEmail = teacher_dbManager.getUserEmail(forgetuser.Text);
            if (usertxb.Text == originEmail)
            {
                if (ddlUserType.SelectedValue == "TEACHER")
                {
                    bool result = teacher_dbManager.teacherforgotPassword(forgetuser.Text, usertxb.Text);
                    if (result == true)
                    {
                        FormsAuthentication.RedirectFromLoginPage(forgetuser.Text, false);
                        Response.Redirect("securitycheck.aspx");
                    }
                }
            }
            else
            {
                Messagelbl.Text="Your provided email address is not the same with the original one.";
            }

       }
    }
}